#coding=utf8

from apscheduler.schedulers.blocking import BlockingScheduler
import time

class Sched():
    def __init__(self):
        self.sched = BlockingScheduler()

    def my_job(self):
        print('Hello World!')

    def start(self):
        self.sched.start()

    def check_sched_status(self):
        if self.sched is None:
            return False
        else:
            return True

def main():
    sche = Sched()
    sche.sched.add_job(sche.my_job, 'interval', seconds=5)
    sche.start()
    while True:
        if sche is None:
            sche = Sched()
            sche.sched.add_job(sche.my_job, 'interval', seconds=5)
            sche.start()
        else:
            if sche.check_sched_status() is False:
                sche.sched = BlockingScheduler()
                sche.sched.add_job(sche.my_job, 'interval', seconds=5)
                sche.sched.start()
        time.sleep(1)

if __name__ == '__main__':
    main()